# coding=utf-8

import copy
import unittest
import time
import json
from .RMNData import RMNData
#见学习992
from .RMNApi import RMNApiClient
#from RTS.RtsApiTest import RTSApiClient, RTSData
#from roxe_libs import ApiUtils
#from roxepy.clroxe import Clroxe
from decimal import Decimal
from requests.exceptions import HTTPError


class BaseCheckRMN(unittest.TestCase):
    client = None
    chain_client = None
    #rts_client = None

    @classmethod
    def setUpClass(cls) -> None:
        cls.client = RMNApiClient(RMNData.host, RMNData.env, RMNData.api_key, RMNData.sec_key, check_db=RMNData.is_check_db, sql_cfg=RMNData.sql_cfg, node_rsa_key=RMNData.node_rsa_key)

    @classmethod
    def tearDownClass(cls) -> None:
        if RMNData.is_check_db:
            cls.client.mysql.disconnect_database()

    # 封装处理流程函数

    def getAndcheckTransactionStatus(self, from_node, api_key, sec_key, msgId, instgAgt, expect_key, txId=None, endToEndId=None, instrId=None, instdPty=None, msgTp=None):
        ts_headers = self.client.make_header(from_node, api_key, "RTSQ")
        msg_header = self.client.make_msg_header(from_node, ts_headers["msgId"])
        txQryDef = self.client.make_RTSQ_information(msgId, instgAgt, txId, endToEndId, instrId, instdPty, msgTp=msgTp)
        time.sleep(3)
        q_info, q_msg = self.client.get_transaction_status(sec_key, ts_headers, msg_header, txQryDef)

        if isinstance(expect_key, list):
            self.assertIn(q_info["data"]["rptOrErr"]["pmt"]["sts"], expect_key)
        else:
            self.assertEqual(q_info["data"]["rptOrErr"]["pmt"]["sts"], expect_key)




    # To B业务测试用例


class RMNApiTest(BaseCheckRMN):
    @classmethod
    def setUpClass(cls) -> None:
        super().setUpClass()



    def test_023_sn_sn_cdtrAgtGiveSNRoxeId_sameCurrency(self):
        """
        主流程: sn_sn, cdtrAgt有roxeId, 且为SN, cdtrIntrmyAgt及intrmyAgt为空
        """
        